package com.easylinkin.sm.entity;

import javax.persistence.AttributeOverride;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.FieldNameConstants;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import site.morn.framework.entity.BasePrivilege;

/**
 * 菜单权限实体
 *
 * @author tulinli
 * @author TianGanLin
 * @since 0.1.1, 2019/5/28
 */
@AttributeOverride(name = "id", column = @Column(name = "id_"))
@AttributeOverride(name = "name", column = @Column(name = "name_", length = 32))
@AttributeOverride(name = "parentId", column = @Column(name = "parent_id_"))
@AttributeOverride(name = "level", column = @Column(name = "level_"))
@AttributeOverride(name = "code", column = @Column(name = "privilege_code_"))
@AttributeOverride(name = "searchCode", column = @Column(name = "search_code_"))
@AttributeOverride(name = "type", column = @Column(name = "type_"))
@AttributeOverride(name = "url", column = @Column(name = "url_"))
@AttributeOverride(name = "sort", column = @Column(name = "seq_"))
@AttributeOverride(name = "description", column = @Column(name = "description_"))
@AttributeOverride(name = "modifier", column = @Column(name = "modifier_", length = 32))
@AttributeOverride(name = "modifyTime", column = @Column(name = "modify_time_"))
@AttributeOverride(name = "creator", column = @Column(name = "creator_", length = 32))
@AttributeOverride(name = "createTime", column = @Column(name = "create_time_"))
@Data
@DynamicInsert
@DynamicUpdate
@Entity
@EqualsAndHashCode(callSuper = true)
@FieldNameConstants
@Table(name = "sm_privilege")
public class Privilege extends BasePrivilege {

  /**
   * 是否为操作日志(1是,0否)
   */
  @Column(name = "is_log_")
  private Integer isLog;


  public Privilege() {

  }

  public Privilege(String code) {
    this();
    super.code = code;
  }

  public Privilege(Long id, Long parentId, String name, String url,
      Integer seq, String privilegeCode) {
    super();
    this.id = id;
    this.parentId = parentId;
    this.name = name;
    this.url = url;
    this.sort = seq;
    this.code = privilegeCode;
  }

  public Privilege(Long id, Long parentId, String name, Integer level) {
    super();
    this.id = id;
    this.parentId = parentId;
    this.name = name;
    this.level = level;
  }
}
